<template>
	<view>
		<!-- 房屋基本信息 -->
		<view class="title">
			<text>润华商厦/1单元/1001</text>
			<text>未缴订单数：<text style="color: red;">4</text></text>
		</view>
		<!-- 账单列表 -->
		<view class="content">
			<checkbox-group>
				<view class="list" v-for="(item,index) in items" :key="index">
					<view>{{item.time}}</view>
					<view class="item">
						<view class="flex">
							<!-- <checkbox style="transform:scale(0.7);" :checked="item.checked" @change="selectItem($event,index)" /> -->
							<image :src="item.iconSrc" style="display: inline-block;width: 20px;height: 18.5px;margin-top: 5rpx;margin-right: 10rpx;" @click="selectItem($event,index)"></image>
							<view style="width: 100%;">
								<view class="info">
									<view>表类型： <text>{{item.type}}</text></view>
									<view>
										<text style="font-size: 24rpx;">￥</text>
										<text style="font-size: 30rpx;">{{item.value}}</text>
									</view>
								</view>
								<view class="detailed">
									<view>
										<text style="padding-right: 20rpx;">￥{{item.value}}</text>
										<text style="padding-right: 20rpx;">{{item.type}}</text>
										<text>
											<text>2019-04-01</text>
											<text>至今</text>
											<text>2019-04-02</text>
										</text>
									</view>
									<view class="late-fee" v-show="item.lateFee != 0">
										<text style="padding-right: 20rpx;">￥{{item.lateFee}}</text>
										<text style="padding-right: 20rpx;">滞纳金</text>
										<text>
											<text>2019-04-01</text>
											<text>至今</text>
											<text>2019-04-02</text>
										</text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</checkbox-group>
		</view>
		<!-- 支付 -->
		<view class="pay">
			<view>
				<label>
					<!-- <checkbox style="transform:scale(0.7);" :checked="select_all" @change="selectAll(e)" /><text>全选</text> -->
					<image :src="iconSrc" style="display: inline-block;width: 18.5px;height: 18.5px;margin-right: 10rpx;vertical-align: middle;margin-bottom: 10rpx;" @click="selectAll(e)"></image><text>全选</text>
				</label>
			</view>
			<view>
				<text>合计：</text>
				<text>
					<text style="font-size: 24rpx;">￥</text>
					<text>0.00</text>
				</text>
			</view>
			<view>
				<view class="button" @click="pay">立即缴费</view>
			</view>
		</view>
	</view>
</template>

<script>
	import uniIcons from '@/components/uni-icons/uni-icons.vue'
	export default {
		components: {
			uniIcons
		},
		mounted(){
			for (var i = 0, lenI = this.items.length; i < lenI; ++i) {
			    const item = this.items[i];
				this.$set(item,'iconSrc','../../static/checkbox/check.png');
			}
		},
		data() {
			return {
				items:[
					{type: '电', time: '2019-02', value: '34', lateFee: '2'},
					{type: '电', time: '2019-03', value: '34', lateFee: '0'},
					{type: '电', time: '2019-04', value: '34', lateFee: '0'},
					{type: '电', time: '2019-05', value: '34', lateFee: '2'}
				],
				select_all: false,
				selectCount: 0,
				detailedShow: false,
				icon: '1',
				de: '',
				iconSrc: '../../static/checkbox/check.png'
			}
		},
		methods: {
			selectAll(e){
				if(this.selectCount != this.items.length){
					this.iconSrc = '../../static/checkbox/checked.png';
					this.selectCount = this.items.length;
					for (var i = 0, lenI = this.items.length; i < lenI; ++i) {
					    const item = this.items[i]
					    this.$set(item,'checked',true);
						this.$set(item,'iconSrc','../../static/checkbox/checked.png');
					}
				}else{
					this.iconSrc = '../../static/checkbox/check.png';
					this.selectCount = 0;
					for (var i = 0, lenI = this.items.length; i < lenI; ++i) {
					    const item = this.items[i]
					    this.$set(item,'checked',false);
						this.$set(item,'iconSrc','../../static/checkbox/check.png');
					}
				}
				this.select_all = !this.select_all;
			},
			selectItem(e,index){
				if(!this.items[index].checked){
					this.items[index].checked = true;
					this.items[index].iconSrc = '../../static/checkbox/checked.png';
					this.selectCount++;
				}else{
					this.items[index].checked = false;
					this.items[index].iconSrc = '../../static/checkbox/check.png';
					this.selectCount--;
				}
				if(this.selectCount == this.items.length){
					this.iconSrc = '../../static/checkbox/checked.png';
				}else{
					this.iconSrc = '../../static/checkbox/check.png';
				}
			},
			detailed (index) {
				this.de = index;
				if (this.icon == 1) {
					this.detailedShow = true;
					this.icon = 2
				} else {
					this.detailedShow = false;
					this.icon = 1
				}
			},
			pay () {
				dd.navigateTo({
				    url: '../payment/payment'
				});
			}
		}
	}
</script>

<style>
	page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		background-color: #efeff4
	}
	
	view {
		font-size: 28rpx;
		line-height: inherit
	}
	.title {
		background-color: #FFFFFF;
		padding: 40rpx;
		display: flex;
		justify-content: space-between;
	}
	.content {
		margin: 40rpx;
		margin-bottom: 150rpx;
	}
	.content .item {
		background-color: #FFFFFF;
		padding: 30rpx;
		margin-bottom: 30rpx;
	}
	.content .item .flex {
		display: flex;
		justify-content: flex-start;
	}
	.content .item .info {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.detailed {
		padding-top: 10rpx;
		color: #999;
		width: 100%;
		text-align: left;
	}
	
	.pay {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		overflow: hidden;
		width: 100%;
		background-color: #FFFFFF;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx 40rpx;
	}
	checkbox {
		border-radius: 50%;
	}
	.button {
		padding: 10rpx 60rpx;
		text-align: center;
		background-color: red;
		color: #FFFFFF;
		margin-right: 80rpx;
	}
</style>
